package com.ruoyi.web.controller.cs;

import java.util.List;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.utils.poi.Excel2Util;
import com.ruoyi.cs.domain.vo.TUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.TUserFeedback;
import com.ruoyi.cs.service.ITUserFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户反馈信息Controller
 * 
 * @author ruoyi
 * @date 2021-05-25
 */
@Api(tags = "用户反馈信息")
@RestController
@RequestMapping("/cs/feedback")
public class TUserFeedbackController extends BasicsController
{
    @Autowired
    private ITUserFeedbackService tUserFeedbackService;

    /**
     * 查询用户反馈信息列表
     */
    @ApiOperation("查询用户反馈信息列表")
    @PreAuthorize("@ss.hasPermi('cs:feedback:list')")
    @RequestMapping(name="用户反馈信息列表",value="list",method = RequestMethod.POST)
    public ResponsePageInfo<TUserFeedback> list(@RequestBody  TUserFeedback tUserFeedback)
    {
        startPage(tUserFeedback.getPageNum(),tUserFeedback.getPageSize());
        List<TUserFeedback> list = tUserFeedbackService.selectTUserFeedbackList(tUserFeedback);
        return toResponsePageInfo(list);
    }

    /**
     * 审核反馈信息
     */
    @ApiOperation("审核反馈信息")
    @PreAuthorize("@ss.hasPermi('system:feedback:audit')")
    @RequestMapping(name="用户反馈信息审核",value="audit",method = RequestMethod.POST)
    public Response audit(@RequestBody TUserFeedback tUserFeedback)
    {
        //return new AjaxResult(Constants.FAILCODE,"此功能暂停使用！");
        return toResponse(tUserFeedbackService.updateTUserFeedback(tUserFeedback));
    }

    /**
     * 导出用户反馈信息列表
     */
    @ApiOperation("导出用户反馈信息列表")
    @PreAuthorize("@ss.hasPermi('system:feedback:export')")
    @Log(title = "用户反馈信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public Response<String> export(TUserFeedback tUserFeedback)
    {
        List<TUserFeedback> list = tUserFeedbackService.selectTUserFeedbackList(tUserFeedback);
        Excel2Util<TUserFeedback> util = new Excel2Util<TUserFeedback>(TUserFeedback.class);
        return util.exportExcel(list, "feedback");
    }

    /**
     * 获取用户反馈信息详细信息
     */
    @ApiOperation("获取用户反馈信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:feedback:query')")
    @GetMapping(value = "/{id}")
    public Response<TUserFeedback> getInfo(@PathVariable("id") String id)
    {
        return Response.success(tUserFeedbackService.selectTUserFeedbackById(id));
    }

    /**
     * 修改用户反馈信息
     */
    @ApiOperation("修改用户反馈信息")
    @PreAuthorize("@ss.hasPermi('system:feedback:edit')")
    @Log(title = "用户反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<Integer> edit(@RequestBody TUserFeedback tUserFeedback)
    {
        return toResponse(tUserFeedbackService.updateTUserFeedback(tUserFeedback));
    }

    /**
     * 删除用户反馈信息
     */
    @ApiOperation("删除用户反馈信息")
    @PreAuthorize("@ss.hasPermi('system:feedback:remove')")
    @Log(title = "用户反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Response<Integer> remove(@PathVariable String[] ids)
    {
        return toResponse(tUserFeedbackService.deleteTUserFeedbackByIds(ids));
    }

    /**-----------------------------------------前端---------------------------------*/
    /**
     * 用户反馈
     */
    @ApiOperation("web用户反馈")
    @RequestMapping(name="用户反馈",value="add",method = RequestMethod.POST)
    public Response<Integer> add(@RequestBody TUserFeedback tUserFeedback)
    {
        //return new AjaxResult(Constants.FAILCODE,"此功能暂停使用！");
        return tUserFeedbackService.insertTUserFeedback(tUserFeedback);
    }
}
